﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using FRL.DebtChased.WorkflowObjects;

namespace FRL.DebtChased.ChaseWorkspace
{

	/// <summary>
	/// Declaration of ChaseAccountMenuCtrl class
	/// Drop-down menu showing accounts in the chase-session, and there priority
	/// </summary>
	public partial class ChaseAccountMenuCtrl : UserControl
	{

		/////////////////////////////////////////////////////////////
		// Construction

		public ChaseAccountMenuCtrl()
		{

			// Initialize member variables
			InitializeComponent();

		}

		/////////////////////////////////////////////////////////////
		// Event handlers

		private void lstChaseAccount_SelectionChanged(object sender, SelectionChangedEventArgs e)
		{

			// TODO
			// Decide whether or not to load account when user clicks menu item

		}

		/////////////////////////////////////////////////////////////
		// Operations

		public void PreVisible()
		{

			// Bind the listbox to the cached data
			lstChaseAccount.ItemsSource = CachedData.Singleton.ChaseItems;

			// Colour the grid
			for (int iIndex = 0; iIndex < lstChaseAccount.Items.Count; iIndex++)
			{

				// Get the chase item
				CachedData.ChaseSessionItem item = lstChaseAccount.Items[iIndex] as CachedData.ChaseSessionItem;

				// TODO
				// When design agreed, put animation for drop-down flow of menu items here

			}

		}

	}

	/// <summary>
	/// Declaration of PriorityToColorConverter class
	/// Converts priority to brush in xaml
	/// </summary>
    public class PriorityToColorConverter : IValueConverter
    {

		/////////////////////////////////////////////////////////////
		// Implementation

        public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
        {
			WorkflowAction_Base.ePriority Priority = (WorkflowAction_Base.ePriority)value;
			if (Priority == WorkflowAction_Base.ePriority.Low)
				return new SolidColorBrush(Colors.Green);
			else
			if (Priority == WorkflowAction_Base.ePriority.Medium)
				return new SolidColorBrush(Colors.Orange);
			else
			if (Priority == WorkflowAction_Base.ePriority.High)
				return new SolidColorBrush(Colors.Red);
            else
                return new SolidColorBrush(Colors.Transparent);
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

    }

}
 
